package com.pxmeta.admin.controller;


import cn.dev33.satoken.annotation.SaCheckLogin;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.collect.Maps;
import com.pxmeta.common.core.domain.AjaxResult;
import com.pxmeta.common.core.redis.RedisCache;
import com.pxmeta.common.utils.SecurityUtils;
import com.pxmeta.party.entity.ActivityAdAstra;
import com.pxmeta.party.entity.Gift;
import com.pxmeta.party.entity.Party;
import com.pxmeta.party.entity.TurntableNumber;
import com.pxmeta.party.entity.dto.ActivityAdAstraDTO;
import com.pxmeta.party.entity.dto.AdAstraConfirmDispatchDTO;
import com.pxmeta.party.entity.vo.ActivityAdAstraDispatchResultVO;
import com.pxmeta.party.entity.vo.ActivityAdAstraRecordVO;
import com.pxmeta.party.entity.vo.ActivityAdAstraUserRankingVO;
import com.pxmeta.party.service.*;
import com.pxmeta.user.entity.User;
import com.pxmeta.user.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/activity")
@Api(value = "派对活动",tags = "派对活动")
@RequiredArgsConstructor
@CrossOrigin
public class ActivityController {
    private final IActivityAdAstraService activityAdAstraService;
    private final IActivityAdAstraRecordService activityAdAstraRecordService;
    private final ITurntableNumberService turntableNumberService;


    @GetMapping("/getActivityList")
    @ApiOperation("获取活动列表")
    public AjaxResult getStarList(@RequestParam Integer page,
                                  @RequestParam Integer size,
                                  @RequestParam Integer type){
        if (type == 7){
            IPage<ActivityAdAstra> result = activityAdAstraService.getStarList(page, size);
            return AjaxResult.successPage(result.getRecords(), result.getTotal());
        }
        return AjaxResult.error();
    }

    @PutMapping("/updateAstra")
    @ApiOperation("更新星球")
    public AjaxResult updateAstra(@RequestBody ActivityAdAstra dto){
        activityAdAstraService.updateById(dto);
        return AjaxResult.success();
    }


    @GetMapping("/getAstraNumber")
    @ApiOperation("获取星球数据")
    public AjaxResult getAstraNumber(){
        TurntableNumber turntableNumber = turntableNumberService.getTurntableNumber(7);
        return AjaxResult.success(turntableNumber);
    }


    @GetMapping("/getLastAstraNumber")
    @ApiOperation("获取上次星球数据")
    public AjaxResult getLastAstraNumber(){
        TurntableNumber turntableNumber = turntableNumberService.getLastAstraNumber(7);
        return AjaxResult.success(turntableNumber);
    }



}
